package cn.ibizlab.odoo.core.odoo_account.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report;
import cn.ibizlab.odoo.core.odoo_account.domain.Account_invoice_report;
import cn.ibizlab.odoo.core.odoo_account.filter.Account_invoice_reportSearchContext;
import cn.ibizlab.odoo.core.odoo_account.service.IAccount_invoice_reportService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[发票统计] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Account_invoice_reportServiceImpl implements IAccount_invoice_reportService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Iaccount_invoice_reportClientService account_invoice_reportClientService;

    @Override
    public void updateBatch(List<Account_invoice_report> account_invoice_reports, int batchSize) {

        //account_invoice_reportClientService.updateBatch(account_invoice_reports,batchSize) ;

    }

    @Override
    public Account_invoice_report get(Integer id) {
        Iaccount_invoice_report clientModel = account_invoice_reportClientService.createModel();
        clientModel.setId(id);
        account_invoice_reportClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Account_invoice_report get(Account_invoice_report account_invoice_report) {
        Account_invoice_report retaccount_invoice_report = this.get(account_invoice_report.getId()) ;
    	BeanCopier copier=BeanCopier.create(retaccount_invoice_report.getClass(), account_invoice_report.getClass(), false);
        copier.copy(retaccount_invoice_report, account_invoice_report, null);
        return account_invoice_report ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //account_invoice_reportClientService.removeBatch(account_invoice_reports) ;

    }

    @Override
    public void createBatch(List<Account_invoice_report> account_invoice_reports, int batchSize) {

                        //account_invoice_reportClientService.createBatch(account_invoice_reports,batchSize) ;

    }

    @Override
    public boolean create(Account_invoice_report account_invoice_report) {
        boolean bOk = false ;
        Iaccount_invoice_report clientModel = this.convert2Model(account_invoice_report,null);
        account_invoice_reportClientService.create(clientModel) ;
        this.convert2Domain(clientModel,account_invoice_report);
        bOk = true ;

        return bOk ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Iaccount_invoice_report clientModel = account_invoice_reportClientService.createModel();
        clientModel.setId(id);
        account_invoice_reportClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public boolean update(Account_invoice_report account_invoice_report) {
        boolean bOk = false ;
        Iaccount_invoice_report clientModel = this.convert2Model(account_invoice_report,null);
        account_invoice_reportClientService.update(clientModel) ;
        this.convert2Domain(clientModel,account_invoice_report) ;
        bOk = true;
        return bOk ;
    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Account_invoice_report> searchDefault(Account_invoice_reportSearchContext context) {
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据科目查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_account(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据科目查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_account_line(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据分析账户查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_account_analytic(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据税科目调整查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_fiscal_position(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据发票查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_invoice(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据日记账查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_journal(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据付款条款查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_payment_term(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据销售渠道查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_team(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品种类查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_categ(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_product(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_company(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据国家/地区查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_country(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_currency(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据银行账户查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_partner_bank(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_commercial_partner(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_partner(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_invoice_report> selectByOdoo_user(Integer id){
        Account_invoice_reportSearchContext context = new Account_invoice_reportSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice_report> list = new ArrayList<Account_invoice_report>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report> clientModelList = account_invoice_reportClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice_report clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice_report>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Iaccount_invoice_report convert2Model(Account_invoice_report domain , Iaccount_invoice_report model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = account_invoice_reportClientService.createModel() ;
        }

         if(domain.getNumberDirtyFlag())
            model.setNumber(domain.getNumber());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getProduct_qtyDirtyFlag())
            model.setProduct_qty(domain.getProduct_qty());
         if(domain.getUser_currency_price_totalDirtyFlag())
            model.setUser_currency_price_total(domain.getUser_currency_price_total());
         if(domain.getResidualDirtyFlag())
            model.setResidual(domain.getResidual());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getDate_dueDirtyFlag())
            model.setDate_due(domain.getDate_due());
         if(domain.getNbrDirtyFlag())
            model.setNbr(domain.getNbr());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getDateDirtyFlag())
            model.setDate(domain.getDate());
         if(domain.getAmount_totalDirtyFlag())
            model.setAmount_total(domain.getAmount_total());
         if(domain.getUom_nameDirtyFlag())
            model.setUom_name(domain.getUom_name());
         if(domain.getPrice_averageDirtyFlag())
            model.setPrice_average(domain.getPrice_average());
         if(domain.getCurrency_rateDirtyFlag())
            model.setCurrency_rate(domain.getCurrency_rate());
         if(domain.getPrice_totalDirtyFlag())
            model.setPrice_total(domain.getPrice_total());
         if(domain.getUser_currency_price_averageDirtyFlag())
            model.setUser_currency_price_average(domain.getUser_currency_price_average());
         if(domain.getUser_currency_residualDirtyFlag())
            model.setUser_currency_residual(domain.getUser_currency_residual());
         if(domain.getTypeDirtyFlag())
            model.setType(domain.getType());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getTeam_id_textDirtyFlag())
            model.setTeam_id_text(domain.getTeam_id_text());
         if(domain.getAccount_analytic_id_textDirtyFlag())
            model.setAccount_analytic_id_text(domain.getAccount_analytic_id_text());
         if(domain.getCateg_id_textDirtyFlag())
            model.setCateg_id_text(domain.getCateg_id_text());
         if(domain.getJournal_id_textDirtyFlag())
            model.setJournal_id_text(domain.getJournal_id_text());
         if(domain.getFiscal_position_id_textDirtyFlag())
            model.setFiscal_position_id_text(domain.getFiscal_position_id_text());
         if(domain.getInvoice_id_textDirtyFlag())
            model.setInvoice_id_text(domain.getInvoice_id_text());
         if(domain.getCountry_id_textDirtyFlag())
            model.setCountry_id_text(domain.getCountry_id_text());
         if(domain.getCurrency_id_textDirtyFlag())
            model.setCurrency_id_text(domain.getCurrency_id_text());
         if(domain.getPayment_term_id_textDirtyFlag())
            model.setPayment_term_id_text(domain.getPayment_term_id_text());
         if(domain.getPartner_id_textDirtyFlag())
            model.setPartner_id_text(domain.getPartner_id_text());
         if(domain.getAccount_line_id_textDirtyFlag())
            model.setAccount_line_id_text(domain.getAccount_line_id_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getCommercial_partner_id_textDirtyFlag())
            model.setCommercial_partner_id_text(domain.getCommercial_partner_id_text());
         if(domain.getProduct_id_textDirtyFlag())
            model.setProduct_id_text(domain.getProduct_id_text());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getAccount_id_textDirtyFlag())
            model.setAccount_id_text(domain.getAccount_id_text());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getCountry_idDirtyFlag())
            model.setCountry_id(domain.getCountry_id());
         if(domain.getPartner_bank_idDirtyFlag())
            model.setPartner_bank_id(domain.getPartner_bank_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getCateg_idDirtyFlag())
            model.setCateg_id(domain.getCateg_id());
         if(domain.getCommercial_partner_idDirtyFlag())
            model.setCommercial_partner_id(domain.getCommercial_partner_id());
         if(domain.getAccount_idDirtyFlag())
            model.setAccount_id(domain.getAccount_id());
         if(domain.getPartner_idDirtyFlag())
            model.setPartner_id(domain.getPartner_id());
         if(domain.getPayment_term_idDirtyFlag())
            model.setPayment_term_id(domain.getPayment_term_id());
         if(domain.getAccount_analytic_idDirtyFlag())
            model.setAccount_analytic_id(domain.getAccount_analytic_id());
         if(domain.getFiscal_position_idDirtyFlag())
            model.setFiscal_position_id(domain.getFiscal_position_id());
         if(domain.getJournal_idDirtyFlag())
            model.setJournal_id(domain.getJournal_id());
         if(domain.getAccount_line_idDirtyFlag())
            model.setAccount_line_id(domain.getAccount_line_id());
         if(domain.getTeam_idDirtyFlag())
            model.setTeam_id(domain.getTeam_id());
         if(domain.getCurrency_idDirtyFlag())
            model.setCurrency_id(domain.getCurrency_id());
         if(domain.getInvoice_idDirtyFlag())
            model.setInvoice_id(domain.getInvoice_id());
        return model ;
    }

    public Account_invoice_report convert2Domain( Iaccount_invoice_report model ,Account_invoice_report domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Account_invoice_report();
        }

        if(model.getNumberDirtyFlag())
            domain.setNumber(model.getNumber());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getProduct_qtyDirtyFlag())
            domain.setProduct_qty(model.getProduct_qty());
        if(model.getUser_currency_price_totalDirtyFlag())
            domain.setUser_currency_price_total(model.getUser_currency_price_total());
        if(model.getResidualDirtyFlag())
            domain.setResidual(model.getResidual());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getDate_dueDirtyFlag())
            domain.setDate_due(model.getDate_due());
        if(model.getNbrDirtyFlag())
            domain.setNbr(model.getNbr());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getDateDirtyFlag())
            domain.setDate(model.getDate());
        if(model.getAmount_totalDirtyFlag())
            domain.setAmount_total(model.getAmount_total());
        if(model.getUom_nameDirtyFlag())
            domain.setUom_name(model.getUom_name());
        if(model.getPrice_averageDirtyFlag())
            domain.setPrice_average(model.getPrice_average());
        if(model.getCurrency_rateDirtyFlag())
            domain.setCurrency_rate(model.getCurrency_rate());
        if(model.getPrice_totalDirtyFlag())
            domain.setPrice_total(model.getPrice_total());
        if(model.getUser_currency_price_averageDirtyFlag())
            domain.setUser_currency_price_average(model.getUser_currency_price_average());
        if(model.getUser_currency_residualDirtyFlag())
            domain.setUser_currency_residual(model.getUser_currency_residual());
        if(model.getTypeDirtyFlag())
            domain.setType(model.getType());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getTeam_id_textDirtyFlag())
            domain.setTeam_id_text(model.getTeam_id_text());
        if(model.getAccount_analytic_id_textDirtyFlag())
            domain.setAccount_analytic_id_text(model.getAccount_analytic_id_text());
        if(model.getCateg_id_textDirtyFlag())
            domain.setCateg_id_text(model.getCateg_id_text());
        if(model.getJournal_id_textDirtyFlag())
            domain.setJournal_id_text(model.getJournal_id_text());
        if(model.getFiscal_position_id_textDirtyFlag())
            domain.setFiscal_position_id_text(model.getFiscal_position_id_text());
        if(model.getInvoice_id_textDirtyFlag())
            domain.setInvoice_id_text(model.getInvoice_id_text());
        if(model.getCountry_id_textDirtyFlag())
            domain.setCountry_id_text(model.getCountry_id_text());
        if(model.getCurrency_id_textDirtyFlag())
            domain.setCurrency_id_text(model.getCurrency_id_text());
        if(model.getPayment_term_id_textDirtyFlag())
            domain.setPayment_term_id_text(model.getPayment_term_id_text());
        if(model.getPartner_id_textDirtyFlag())
            domain.setPartner_id_text(model.getPartner_id_text());
        if(model.getAccount_line_id_textDirtyFlag())
            domain.setAccount_line_id_text(model.getAccount_line_id_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getCommercial_partner_id_textDirtyFlag())
            domain.setCommercial_partner_id_text(model.getCommercial_partner_id_text());
        if(model.getProduct_id_textDirtyFlag())
            domain.setProduct_id_text(model.getProduct_id_text());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getAccount_id_textDirtyFlag())
            domain.setAccount_id_text(model.getAccount_id_text());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getCountry_idDirtyFlag())
            domain.setCountry_id(model.getCountry_id());
        if(model.getPartner_bank_idDirtyFlag())
            domain.setPartner_bank_id(model.getPartner_bank_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getCateg_idDirtyFlag())
            domain.setCateg_id(model.getCateg_id());
        if(model.getCommercial_partner_idDirtyFlag())
            domain.setCommercial_partner_id(model.getCommercial_partner_id());
        if(model.getAccount_idDirtyFlag())
            domain.setAccount_id(model.getAccount_id());
        if(model.getPartner_idDirtyFlag())
            domain.setPartner_id(model.getPartner_id());
        if(model.getPayment_term_idDirtyFlag())
            domain.setPayment_term_id(model.getPayment_term_id());
        if(model.getAccount_analytic_idDirtyFlag())
            domain.setAccount_analytic_id(model.getAccount_analytic_id());
        if(model.getFiscal_position_idDirtyFlag())
            domain.setFiscal_position_id(model.getFiscal_position_id());
        if(model.getJournal_idDirtyFlag())
            domain.setJournal_id(model.getJournal_id());
        if(model.getAccount_line_idDirtyFlag())
            domain.setAccount_line_id(model.getAccount_line_id());
        if(model.getTeam_idDirtyFlag())
            domain.setTeam_id(model.getTeam_id());
        if(model.getCurrency_idDirtyFlag())
            domain.setCurrency_id(model.getCurrency_id());
        if(model.getInvoice_idDirtyFlag())
            domain.setInvoice_id(model.getInvoice_id());
        return domain ;
    }


}
